package org.example.mapper;

import org.apache.ibatis.annotations.Select;
import org.example.domain.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author txm
 * @since 2021-02-26
 */
public interface PermissionMapper extends BaseMapper<Permission> {


    /*
        注意：当我们将Sql语句直接写在接口方法上时，有一个前提：
              查询语句的条件 必须是 固定个数且必传 即不可变
     */
    @Select("select p.* from permission p,role_permission rp,employee_role er,employee e\n" +
            "        where p.id = rp.permission_id and rp.role_id = er.role_id and  " +
            "er.employee_id = e.id and e.username = #{userName}")
    List<Permission> findAllByEmployeeId(String admin);
}
